package top.laoshuzi.designpatterns.base.behavior.memento;

import org.junit.Test;

public class Client {

    @Test
    public void operation() {

        Caretaker caretaker = new Caretaker();

        //初始化
        Originator originator = new Originator();
        originator.setState("state1");
        System.out.println(originator.getState());

        //保存
        caretaker.saveMemento(originator.createMemento());

        //更改
        originator.setState("state2");
        System.out.println(originator.getState());

        //恢复
        originator.restoreMemento(caretaker.loadMemento());
        System.out.println(originator.getState());


    }
}
